﻿using Md.Api.Model;
using Md.Api.Model.Manage.SysRole.Request;
using Md.Api.Service.Manage.SysRole;
using Microsoft.AspNetCore.Mvc;

namespace Md.Api.Controllers.Manage;
/// <summary>
/// 系统菜单
/// </summary>
[ApiController]
[Produces("application/json")]
[Route("md-api/manage/system/role")]
public class SysRoleController : ControllerBase
{
    /// <summary>
    /// 通过角色编号删除系统角色服务
    /// </summary>
    public DeleteSysRoleByRoleIdService deleteSysRoleByRoleIdService { get; set; }
    /// <summary>
    /// 通过角色编号删除系统角色
    /// </summary>
    /// <param name="roleIds">角色编号多个逗号分割（1,2,3...）</param>
    /// <param name="signModel">加密实体</param>
    /// <returns>ResponseMessageModel</returns>
    [HttpDelete("{roleIds}")]
    public async Task<ResponseMessageModel> DeleteSysRoleByRoleId(string roleIds, [FromQuery] RequestSignModel signModel)
    {
        var model = new RequestDeleteSysRoleByRoleIdModel();

        model.RoleIds = roleIds;
        model.TimesTamp = signModel.TimesTamp;
        model.Mac = signModel.Mac;
        model.Ip = signModel.Ip;
        model.Sign = signModel.Sign;
        model.Version = signModel.Version;
        model.Token = signModel.Token;

        return await Task.Run(() => deleteSysRoleByRoleIdService.Execute(model));
    }

    /// <summary>
    /// 添加系统角色服务
    /// </summary>
    public InsertSysRoleService insertSysRoleService { get; set; }
    /// <summary>
    /// 添加系统角色
    /// </summary>
    /// <param name="model">请求实体</param>
    /// <returns>ResponseMessageModel</returns>
    [HttpPost]
    public async Task<ResponseMessageModel> InsertSysRole([FromBody] RequestInsertSysRoleModel model)
    {
        return await Task.Run(() => insertSysRoleService.Execute(model));
    }

    /// <summary>
    /// 通过角色编号更新系统角色服务
    /// </summary>
    public UpdateSysRoleByRoleIdService updateSysRoleByRoleIdService { get; set; }
    /// <summary>
    /// 通过角色编号更新系统角色
    /// </summary>
    /// <param name="model">请求实体</param>
    /// <returns>ResponseMessageModel</returns>
    [HttpPut]
    public async Task<ResponseMessageModel> UpdateSysRoleByRoleId([FromBody] RequestUpdateSysRoleByRoleIdModel model)
    {
        return await Task.Run(() => updateSysRoleByRoleIdService.Execute(model));
    }

    /// <summary>
    /// 通过角色编号获取系统角色服务
    /// </summary>
    public GetSysRoleByRoleIdService getSysRoleByRoleIdService { get; set; }
    /// <summary>
    /// 通过角色编号获取系统角色
    /// </summary>
    /// <param name="roleId">角色编号</param>
    /// <param name="signModel">加密实体</param>
    /// <returns>ResponseMessageModel</returns>
    [HttpGet("{roleId}")]
    public async Task<ResponseMessageModel> GetSysRoleByRoleId(long roleId, [FromQuery] RequestSignModel signModel)
    {
        var model = new RequestGetSysRoleByRoleIdModel();

        model.RoleId = roleId;
        model.TimesTamp = signModel.TimesTamp;
        model.Mac = signModel.Mac;
        model.Ip = signModel.Ip;
        model.Sign = signModel.Sign;
        model.Version = signModel.Version;
        model.Token = signModel.Token;

        return await Task.Run(() => getSysRoleByRoleIdService.Execute(model));
    }

    /// <summary>
    /// 获取系统角色列表服务
    /// </summary>
    public GetSysRoleListService getSysRoleListService { get; set; }
    /// <summary>
    /// 获取系统角色列表
    /// </summary>
    /// <param name="model">请求实体</param>
    /// <returns>ResponseMessageModel</returns>
    [Route("list"), HttpPost]
    public async Task<ResponseMessageModel> GetSysRoleList([FromBody] RequestGetSysRoleListModel model)
    {
        return await Task.Run(() => getSysRoleListService.Execute(model));
    }

    /// <summary>
    /// 分页获取系统角色列表服务
    /// </summary>
    public GetSysRolePageListService getSysRolePageListService { get; set; }
    /// <summary>
    /// 分页获取系统角色列表
    /// </summary>
    /// <param name="model">请求实体</param>
    /// <returns>ResponseMessageModel</returns>
    [Route("listPage"), HttpPost]
    public async Task<ResponseMessageModel> GetSysRolePageList([FromBody] RequestGetSysRolePageListModel model)
    {
        return await Task.Run(() => getSysRolePageListService.Execute(model));
    }
}

